<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计数器</title>
    <link rel="stylesheet" href="./common.css">
    <style>
        #app{
            width: 300px;
            height: 30px;
            /* margin: 200px auto; */
            display: flex;
        }
        button{
            width: 50px;
            height: 30px;
            background-color: rgb(209, 208, 208);
            /* font-size: 30px; */
            border: transparent;
        }
        span{
            box-sizing: border-box;
            /* display: inline-block; */
            width: 120px;
            height: 30px;
            border:1px rgb(192, 190, 190) solid;
            text-align: center;
            line-height: 30px;
            vertical-align: top;
        }
    </style>
</head>
<body>
    <!-- 开发版本环境 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <div id="app">
        <button @click="reduce">-</button>
        <span>{{num}}</span>
        <button @click="add"> + </button>
    </div>
    <script>
        var app = new Vue({
            el:"#app",
            data:{
                num:1
            },
            methods:{
                add:function(){
                    if(this.num<10){
                        this.num++;
                    }else{
                        alert("别加了")
                    }
                },
                reduce:function(){
                    if(this.num>0){
                        this.num--;
                    }else{
                        alert("别减了")
                    }
                }
            }
        })
    </script>
</body>
</html>